package me.minecraft.mod.resourcepackdemo.mixin;

import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
 * @author langle__
 * @version 1.0
 */
@Mixin(Identifier.class)
public abstract class IdentifierMixin {

    @Inject(method = "isPathCharacterValid", at = @At("HEAD"), cancellable = true)
    private static void isPathCharacterValid(char c, CallbackInfoReturnable<Boolean> cir) {
        if (c == '/' || c == '\\') {
            cir.cancel();
            cir.setReturnValue(true);
        }
    }

    @Inject(method = "isNamespaceCharacterValid", at = @At("HEAD"), cancellable = true)
    private static void isNamespaceCharacterValid(char c, CallbackInfoReturnable<Boolean> cir) {
        if (c == '/' || c == '\\') {
            cir.cancel();
            cir.setReturnValue(true);
        }
    }

}
